From: Hannah von Reth Date: Mon, 6 Sep 2021 12:13:01 +0000 (+0200) Subject: Warn if we encounter an unsupported configuration X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~30^2^2~189^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=cb05cedd100269b821af7534bd52ced833f2b94e;p=nextcloud-desktop.git Warn if we encounter an unsupported configuration --- diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 93e559524..fe44f591b 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -44,6 +44,13 @@ constexpr auto settingsAccountsC = "Accounts"; constexpr auto settingsFoldersC = "Folders"; constexpr auto settingsVersionC = "version"; constexpr auto maxFoldersVersion = 1; +const char versionC[] = "version"; + +int numberOfSyncJournals(const QString &path) +{ + return QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).size(); +} + } namespace OCC { @@ -1800,6 +1807,9 @@ static QString checkPathValidityRecursive(const QString &path) Utility::NtfsPermissionLookupRAII ntfs_perm; #endif const QFileInfo selFile(path); + if (numberOfSyncJournals(selFile.filePath()) != 0) { + return FolderMan::tr("The folder %1 is used in a folder sync connection!").arg(QDir::toNativeSeparators(selFile.filePath())); + } if (!FileSystem::fileExists(path)) { QString parentPath = selFile.dir().path(); @@ -2032,4 +2042,15 @@ bool FolderMan::checkVfsAvailability(const QString &path, Vfs::Mode mode) const return unsupportedConfiguration(path) && Vfs::checkAvailability(path, mode); } +Result FolderMan::unsupportedConfiguration(const QString &path) const +{ + if (numberOfSyncJournals(path) > 1) { + return tr("Multiple accounts are sharing the folder %1.\n" + "This configuration is know to lead to dataloss and is no longer supported.\n" + "Please consider removing this folder from the account and adding it again.") + .arg(path); + } + return {}; +} + } // namespace OCC diff --git a/src/gui/folderman.h b/src/gui/folderman.h index f0dafc4f2..ebfebb0b4 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -234,6 +234,8 @@ public: /** Whether or not vfs is supported in the location. */ bool checkVfsAvailability(const QString &path, Vfs::Mode mode = bestAvailableVfsMode()) const; + /** If the folder configuration is no longer supported this will return an error string */ + Result unsupportedConfiguration(const QString &path) const; signals: /** * signal to indicate a folder has changed its sync state. diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index f712cf92c..44b2402c4 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -250,8 +250,15 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const return (folder->syncResult().hasUnresolvedConflicts()) ? QStringList(tr("There are unresolved conflicts. Click for details.")) : QStringList(); - case FolderStatusDelegate::FolderErrorMsg: - return folder->syncResult().errorStrings(); + case FolderStatusDelegate::FolderErrorMsg: { + auto errors = folder->syncResult().errorStrings(); + const auto legacyError = FolderMan::instance()->unsupportedConfiguration(folder->path()); + if (!legacyError) { + // the error message might contain new lines, the delegate only expect multiple single line values + errors.append(legacyError.error().split(QLatin1Char('\n'))); + } + return errors; + } case FolderStatusDelegate::FolderInfoMsg: return folder->virtualFilesEnabled() && folder->vfs().mode() != Vfs::Mode::WindowsCfApi ? QStringList(tr("Virtual file support is enabled.")) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index d5a222527..fe710af3d 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -621,7 +621,7 @@ void FolderWizardSelectiveSync::initializePage() bool FolderWizardSelectiveSync::validatePage() { const auto mode = bestAvailableVfsMode(); - const bool useVirtualFiles = (Theme::instance()->forceVirtualFilesOption() && mode == Vfs::WindowsCfApi) || (_virtualFilesCheckBox && _virtualFilesCheckBox->isChecked()); + const bool useVirtualFiles = (mode == Vfs::WindowsCfApi) || (_virtualFilesCheckBox && _virtualFilesCheckBox->isChecked()); if (useVirtualFiles) { const auto availability = Vfs::checkAvailability(wizard()->field(QStringLiteral("sourceFolder")).toString(), mode); if (!availability) {